<template>
	<view>
		<!-- 		<view class="body">
			<image src="../../static/logo.png" mode="widthFix" class="image"></image>
			<view class="text">缩话</view>
		</view>
		<view class="footer">
			<text></text>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {},
		onShow() {
			console.log("launchPage")
			let token = uni.getStorageSync("token")
			console.log(token)
			if (token !== null && token !== undefined && token !== "") {
				this.$request.TokenRequest({
					url: "/user/updateToken"
				}, {
					token: token
				}).then(res => {
					console.log(res)
					if (res.state === 200) {
						uni.setStorageSync("token", res.data.token)
						this.$store.commit("initLoginState", this.$socket)
						setTimeout(function() {
							// console.log("redirect")
							uni.reLaunch({
								url: '../message/message'
							})
						}, 100)
					} else {
						uni.removeStorageSync("loginState")
						uni.removeStorageSync("token")
						setTimeout(function() {
							// console.log("redirect")
							uni.reLaunch({
								url: "../login/login"
							})
						}, 100)
					}
				}).catch(err => {
					console.log(err)
					setTimeout(function() {
						// console.log("redirect")
						uni.reLaunch({
							url: "../login/login",
							fail(e) {
								console.log(e)
							}
						})
					}, 100)
				})
			} else {
				setTimeout(function() {
					// console.log("redirect")
					uni.reLaunch({
						url: "../login/login",
						fail(e) {
							console.log(e)
						}
					})
				}, 100)
			}
		}
	}
</script>

<style scoped>
	.body {
		text-align: center;
	}

	.image {
		width: 50%;
		margin-top: 300rpx;
	}

	.text {
		margin: 100rpx auto;
		font-size: 100rpx;
	}
</style>
